package com.netsdk.demo.customize.OtherDemo;

import com.netsdk.demo.util.CaseMenu;
import com.netsdk.lib.NetSDKLib;
import com.netsdk.lib.PlaySDKLib;
import com.netsdk.lib.structure.NET_IN_GET_BIND_MODE_INFO;
import com.netsdk.lib.structure.NET_IN_SET_BIND_MODE_INFO;
import com.netsdk.lib.structure.NET_OUT_GET_BIND_MODE_INFO;
import com.netsdk.lib.structure.NET_OUT_SET_BIND_MODE_INFO;
import com.netsdk.lib.utils.Initialization;

public class BindModeDemo extends Initialization {


    /**
     * 变量区
     **/
    int channel = 0;
    static NetSDKLib netsdkApi = NetSDKLib.NETSDK_INSTANCE;
    static NetSDKLib configApi = NetSDKLib.CONFIG_INSTANCE;
    static PlaySDKLib playsdkApi = PlaySDKLib.PLAYSDK_INSTANCE;

    /**方法区**/

    /**
     * SetBindMode
     */
    public void SetBindMode() {
        NET_IN_SET_BIND_MODE_INFO stIn = new NET_IN_SET_BIND_MODE_INFO();
        stIn.nClassRoomId = 1;
        stIn.emBindMode = 2;
        stIn.write();
        NET_OUT_SET_BIND_MODE_INFO stOut = new NET_OUT_SET_BIND_MODE_INFO();
        stOut.write();
        if(netsdkApi.CLIENT_SetBindMode(loginHandle, stIn.getPointer(), stOut.getPointer(), 3000)){
            System.out.println("CLIENT_SetBindMode succeed");
        } else {
            System.err.println("CLIENT_SetBindMode failed");
        }
    }

    /**
     * GetBindMode
     */
    public void GetBindMode() {
        NET_IN_GET_BIND_MODE_INFO stIn = new NET_IN_GET_BIND_MODE_INFO();
        stIn.nClassRoomId = 1;
        stIn.write();
        NET_OUT_GET_BIND_MODE_INFO stOut = new NET_OUT_GET_BIND_MODE_INFO();
        stOut.write();
        if(netsdkApi.CLIENT_GetBindMode(loginHandle, stIn.getPointer(), stOut.getPointer(), 3000)){
            System.out.println("CLIENT_GetBindMode succeed");
            stOut.read();
            System.out.println("emBindMode = " + stOut.emBindMode);
        } else {
            System.err.println("CLIENT_GetBindMode failed");
        }
    }

    public void RunTest() {
        System.out.println("Run Test");
        CaseMenu menu = new CaseMenu();
        menu.addItem((new CaseMenu.Item(this, "SetBindMode", "SetBindMode")));
        menu.addItem((new CaseMenu.Item(this, "GetBindMode", "GetBindMode")));

        menu.run();
    }

    public static void main(String[] args) {
        BindModeDemo demo = new BindModeDemo();
        /**登录信息运行时输入**/
//        Scanner sc = new Scanner(System.in);
//        System.out.print("ip:");
//        String ip = sc.nextLine();
//        System.out.print("port:");
//        String tmp = sc.nextLine();
//        int port = Integer.parseInt(tmp);
//        System.out.print("username:");
//        String username = sc.nextLine();
//        System.out.print("password:");
//        String pwd = sc.nextLine();
//        InitTest(ip, port, username, pwd);
        /**登录信息固定**/
        InitTest("10.55.61.100",37777,"admin","admin123");
        demo.RunTest();
        LoginOut();

    }
}